FHIR © HL7.org  |  Server Home  |  FHIR Server FHIR Server 3.4.11  |  FHIR Version n/a  User: [n/a]

Resource StructureMap/FHIR Server from package ch.fhir.ig.ch-alis#current (125 ms)

Package ch.fhir.ig.ch-alis
Type StructureMap
Id Id
FHIR Version R4
Source http://fhir.ch/ig/ch-alis/https://build.fhir.org/ig/ahdis/ch-alis/StructureMap-Alis43ToBundle.html
Url http://fhir.ch/ig/ch-alis/StructureMap/Alis43ToBundle
Version 0.3.0
Status draft
Date 2024-10-29T15:42:46+00:00
Name Alis43ToBundle
Experimental False
Realm ch
Authority hl7
Description Convert ALIS43 XML to a Bundle according to the CH ALIS implmementation guide, 2020-12-03 by Oliver Egger, copyright ahdis ag, Apache License, FHIR: http://hl7.org/fhir/r4/. ISSUE7: what are the URL's oid's we have to define.
Copyright not-open-source

Resources that use this resource

No resources found


Resources that this resource uses

No resources found



Narrative

Note: links and images are rebased to the (stated) source

/// url = "http://fhir.ch/ig/ch-alis/StructureMap/Alis43ToBundle"
/// name = "Alis43ToBundle"
/// title = "null"
/// status = "draft"

// Convert ALIS43 XML to a Bundle according to the CH ALIS implmementation guide,
// 2020-12-03 by Oliver Egger, copyright ahdis ag, Apache License,
// FHIR: http://hl7.org/fhir/r4/.
// ISSUE7: what are the URL's oid's we have to define.

conceptmap "serviceMap" {
  prefix s = "http://fhir.ch/ig/ch-alis"
  prefix t = "http://hl7.org/fhir"

  s:TARMED == t:"urn:oid:2.16.756.5.30.1.129.1.4"
  s:ICD10 == t:"urn:oid:2.16.756.5.30.1.126.3.2"
}

conceptmap "gender" {
  prefix s = "http://fhir.ch/ig/ch-alis"
  prefix t = "http://hl7.org/fhir/ValueSet/administrative-gender"

  s:M == t:male
  s:F == t:female
}

conceptmap "laterality" {
  prefix s = "http://fhir.ch/ig/ch-alis"
  prefix t = "http://snomed.info/sct"

  s:l == t:"7771000"
  s:r == t:"24028007"
  s:b == t:"51440002"
}

uses "http://fhir.ch/ig/ch-alis/StructureDefinition/Header" alias Header as source
uses "http://fhir.ch/ig/ch-alis/StructureDefinition/Visit" alias Visit as source
uses "http://fhir.ch/ig/ch-alis/StructureDefinition/Service" alias Service as source
uses "http://fhir.ch/ig/ch-alis/StructureDefinition/PersonV40" alias PersonV40 as source
uses "http://fhir.ch/ig/ch-alis/StructureDefinition/ParameterV40" alias ParameterV40 as source
uses "http://fhir.ch/ig/ch-alis/StructureDefinition/DiagGroup" alias DiagGroup as source
uses "http://fhir.ch/ig/ch-alis/StructureDefinition/LeistungsschnittstelleProcedure" alias Proc as source
uses "http://fhir.ch/ig/ch-alis/StructureDefinition/Diagnosis" alias Diagnosis as source
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target
uses "http://hl7.org/fhir/StructureDefinition/ChargeItem" alias ChargeItem as target
uses "http://hl7.org/fhir/StructureDefinition/Extension" alias Extension as target
uses "http://hl7.org/fhir/StructureDefinition/MessageHeader" alias MessageHeader as target
uses "http://hl7.org/fhir/StructureDefinition/BackboneElement" alias BackboneElement as target
uses "http://hl7.org/fhir/StructureDefinition/HumanName" alias HumanName as target
uses "http://hl7.org/fhir/StructureDefinition/Condition" alias Condition as target
uses "http://hl7.org/fhir/StructureDefinition/Encounter" alias Encounter as target
uses "http://hl7.org/fhir/StructureDefinition/Procedure" alias Procedure as target

group Alis43ToBundle(source header : Header, target bundle : Bundle) {
  header ->  bundle.meta as meta,  meta.profile as profile,  profile.value = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-message',  bundle.entry as e,  e.resource = create('MessageHeader') as messageHeader,  messageHeader.id = uuid() as uuid,  e.fullUrl = append('urn:uuid:', uuid),  bundle.entry as e2,  e2.resource = create('Bundle') as transactionBundle,  transactionBundle.id = uuid() as uuid2,  e2.fullUrl = append('urn:uuid:', uuid2),  messageHeader.focus = create('Reference') as reference,  reference.type = 'Bundle',  reference.reference = append('urn:uuid:', uuid2) then {
    header then Alis43ToMessageHeader(header, messageHeader) "messageHeader";
    header then Alis43ToBundleTransaction(header, transactionBundle) "bundleTransaction";
  } "bundle";
  header -> bundle.type = 'message' "type";
  header.FileCreationDate as fileCreationDate then {
    fileCreationDate.data as date -> bundle.timestamp = date "date";
  };
}

group Alis43ToMessageHeader(source header : Header, target messageHeader : MessageHeader) {
  // ISSUE1: should be link to a MessageDefinition or a code?
  header ->  messageHeader.event = create('uri') as value,  value.value = 'http://fhir.ch/ig/ch-alis-43' "eventUri";
  // ISSUE2: MessageControlID cannot be id of entry, needs to be either fullUrl oder uuid, need to map this to an identifier
  header -> messageHeader.source as source then {
    header.SoftwareReleaseNumber as version -> source.version = (%version.data) "version";
    // ISSUE3: " : "urn:SendingApplication:SendingFacility:SendingServiceCode" -> add urn: in example/docu
    header -> source.endpoint = ('urn:' + %header.SendingApplication.data + ':' + %header.SendingFacility.data + ':' + %header.SendingServiceCode.data) "endpoint";
  } "source";
  header -> messageHeader.destination as destination then {
    // ISSUE4: " : "urn:ReceivingApplication, ReceivingFacility, ReceivingServiceCode" -> add urn: in example/docu
    header -> destination.endpoint = ('urn:' + %header.ReceivingApplication.data + ':' + %header.ReceivingFacility.data + ':' + %header.ReceivingServiceCode.data) "endpoint";
  } "destination";
}

group Alis43ToBundleTransaction(source header : Header, target transactionBundle : Bundle) {
  header -> transactionBundle.type = 'transaction' "transaction";
  header.Visit as visit then {
    visit.Service as service ->  transactionBundle.entry as e,  e.resource = create('ChargeItem') as chargeItem then ServiceToChargeItem(service, visit, chargeItem, e) "ServiceToChargeItem";
  };
}

group ServiceToChargeItem(source service : Service, source visit : Visit, target chargeItem : ChargeItem, target entry) {
  service.ItemNumber as itemNumber ->  chargeItem.id = (%itemNumber.data.lower()) as uuid,  entry.fullUrl = append('urn:uuid:', uuid) "R311LaufnummerItemNumber";
  service ->  chargeItem.contained = create('Patient') as patient,  patient.id = 'pat' as containedid,  chargeItem.subject = create('Reference') as ref,  ref.reference = ('#' + %containedid) then ServiceToPatient(service, visit, patient) "patient";
  visit ->  chargeItem.contained = create('Encounter') as encounter,  encounter.id = 'enc' as containedid,  chargeItem.context = create('Reference') as ref,  ref.reference = ('#' + %containedid) then {
    visit then VisitToEncounter(visit, encounter) "VisitToEncounter";
    service.Diagnosis as diag ->  chargeItem.contained = create('Condition') as condition,  condition.id = uuid() as containedid,  encounter.diagnosis as diag,  diag.condition = create('Reference') as ref,  ref.reference = ('#' + %containedid) then DiagnosisToCondition(diag, condition) "DiagnosisToCondition";
  } "encounter";
  visit.DiagGroup as diaggroup ->  chargeItem.contained = create('Condition') as cond,  cond.id = 'cond' as containedid then DiagGroupToCondition(diaggroup, cond) "DiagGroupToCondition";
  service where (service.Transaction.exists() = false) ->  entry.request as request,  request.method = 'POST',  request.url = 'ChargeItem' "POSTDEFAULT";
  service.Transaction where (service.Transaction = 'insert') ->  entry.request as request,  request.method = 'POST',  request.url = 'ChargeItem' "POST";
  service.Transaction where (service.Transaction = 'update') ->  entry.request as request,  request.method = 'PUT',  request.url = 'ChargeItem' "UPDATE";
  service.Transaction where (service.Transaction = 'delete') ->  entry.request as request,  request.method = 'DELETE',  request.url = 'ChargeItem' "DELETE";
  service.SessionID as sessionID ->  chargeItem.extension as extension,  extension.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-sessionid',  extension.value = create('string') as value,  value.value = (%sessionID.data) "R32SitzungSessionID";
  service.OrderID as orderID ->  chargeItem.extension as extension,  extension.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-orderid',  extension.value = create('string') as value,  value.value = (%orderID.data) "R33AuftragsnummerOrderID";
  service.OrderDate as orderDate ->  chargeItem.extension as extension,  extension.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-orderdate',  extension.value = create('dateTime') as value,  value.value = (%orderDate.data) "R33AuftragsnummerOrderID";
  service.Form as form ->  chargeItem.extension as extension,  extension.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-form',  extension.value = create('string') as value,  value.value = (%form.data) "R37FormularbezeichnungForm";
  service.ParameterV40 as parameterV40 ->  chargeItem.extension as extension,  extension.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-parameterv40' then ParameterV40ToExtension(parameterV40, extension) "R4ParamterV40ParameterV40";
  service -> chargeItem.status = 'billable' "billable";
  service.RefItemNumber as refItemNumber then {
    refItemNumber.data as data ->  chargeItem.partOf = create('Reference') as ref,  ref.reference = ('urn:uuid:' + %data.lower()),  ref.type = 'ChargeItem' "R312ReferenzzuHauptleistungRefItemNumber";
  };
  service.ServiceItem as serviceItem then {
    serviceItem.data as data ->  chargeItem.code = create('CodeableConcept') as cc,  cc.coding = create('Coding') as coding,  coding.code = data then {
      service.ServiceType as serviceType then {
        serviceType.data as data -> coding.system = translate(data, '#serviceMap', 'code') "R35KatalogServiceType";
      } "servicType";
    } "R36TarifpositionServiceItem";
  } "R36Tarifposition";
  service.ServiceDate as serviceData ->  chargeItem.occurrence = create('dateTime') as occurrence,  occurrence.value = (%serviceData.data) "R31LeistungsdatumServiceDate";
  service.PersonV40 as personV40 -> chargeItem.performer = create('BackboneElement') as performer then PersonV40ToPerformer(personV40, performer) "R315PersonV40PersonV40";
  service.ProviderID as providerID ->  chargeItem.performingOrganization = create('Reference') as reference,  reference.display = (%providerID.data) "R39ErbringendeOrganizationProviderID";
  service.ReferrerID as referrerID ->  chargeItem.costCenter = create('Reference') as reference,  reference.display = (%referrerID.data) "R34AuftraggebendeKostenstelleReferrerID";
  service.Quantity as quantity ->  chargeItem.quantity = create('Quantity') as q,  q.value as value,  value.value = (%quantity.data) "R313AnzahlQuantity";
  service.EnteredBy as enteredBy ->  chargeItem.enterer = create('Reference') as reference,  reference.display = (%enteredBy.data) "R310ErfasserEnteredBy";
  service.EnteredDateTime as enteredDateTime ->  chargeItem.enteredDate = create('dateTime') as enteredDate,  enteredDate.value = (%enteredDateTime.data) "R38ErfassungsdatumEnteredDateTime";
  service.PatientContactID as patientContactID then {
    patientContactID.data as data ->  chargeItem.identifier = create('Identifier') as identifier,  identifier.value = data "PatientContactID";
  } "patientContactID";
  service.Costweight as costweight then {
    costweight.data as data -> chargeItem.factorOverride = data "Costweight";
  } "costweight";
  service.Procedure as proc ->  chargeItem.contained = create('Procedure') as procedure,  procedure.id = uuid() as containedid,  chargeItem.service = create('Reference') as service,  service.reference = ('#' + %containedid) then ServiceProcedureToFhirProcedure(proc, procedure) "ServiceProcedureToFhirProcedure";
}

group ServiceProcedureToFhirProcedure(source proc : Proc, target procedure : Procedure) {
  proc.Identifier as identifier ->  procedure.identifier = create('Identifier') as identifier,  identifier.value = (%identifier.data) "R314ProzedurIDIdentifier";
  proc.Code as chopcode where (%proc.Category.data = 'CHOP_2023') ->  procedure.code = create('CodeableConcept') as cc,  cc.coding = create('Coding') as coding,  coding.code = (%chopcode.data),  coding.system = 'https://www.bfs.admin.ch/bfs/statistiche/catalog/chop2023',  coding.display = (%proc.Display.data) "R316ProzedurcodeCode";
  proc.PerformedDateTime as performedDateTime -> procedure.performed = (%performedDateTime.data) "R317DatumZeitPerformedDateTime";
  proc.Laterality as laterality then {
    laterality.data as v ->  procedure.bodySite = create('CodeableConcept') as cc,  cc.coding = create('Coding') as coding,  coding.code = translate(v, '#laterality', 'code'),  coding.system = 'http://snomed.info/sct',  coding.display = (%proc.LateralityDisplay.data) "R318SeiteLaterality";
  } "laterality";
  proc.Performer as performer then {
    // TODO Perfomer.function
    performer.Identifier as identifier then {
      identifier.data as data ->  procedure.performer as performer,  performer.actor as actor,  actor.identifier as identifier,  identifier.value = data "identifier";
    };
  } "performer";
  proc ->  procedure.subject = create('Reference') as ref,  ref.reference = '#pat' "containedpatient";
  proc -> procedure.status = 'completed' "status";
}

group PersonV40ToPerformer(source personV40 : PersonV40, target performer) {
  personV40.PersonTyp as personTyp ->  performer.function as cc,  cc.coding as coding,  coding.system as system,  system.value = 'http://fhir.ch/ig/ch-alis/CodeSystem/ch-alis-persontyp',  coding.code as code,  code.value = personTyp "R3152PersonIDPersonID";
  personV40.PersonID as personId ->  performer.actor = create('Reference') as reference,  reference.display = (%personId.data) "R3152PersonIDPersonID";
}

group ParameterV40ToExtension(source parameterV40 : ParameterV40, target extension : Extension) {
  parameterV40.ParamTyp as paramTyp -> extension.extension as extInner then InnerExtensionParamTyp(paramTyp, extInner);
  parameterV40.ParamValue as paramValue then {
    paramValue.data as data -> extension.extension as extInner then InnerExtensionParamValue(data, extInner);
  };
}

group InnerExtensionParamTyp(source src, target ext : Extension) {
  src -> ext.url = 'ParamTyp' "url";
  src ->  ext.value = create('CodeableConcept') as cc,  cc.text as text,  text.value = src "string";
}

group InnerExtensionParamValue(source src, target ext : Extension) {
  src -> ext.url = 'ParamValue' "url";
  src ->  ext.value = create('string') as string,  string.value = src "string";
}

group ServiceToPatientName(source visit : Visit, target name : HumanName) {
  visit.PatientName as patientName then {
    patientName.data as data -> name.family = data "R23PatientNamePatientName";
  } "patientName";
  visit.PatientGivenName as patientGivenName then {
    patientGivenName.data as data -> name.given = data "R24PatientVornamePatientGivenName";
  } "patientGivenName";
}

group ServiceToPatient(source service : Service, source visit : Visit, target patient : Patient) {
  visit.PatientID as patientID then {
    patientID.data as patId ->  patient.identifier as identifier,  identifier.value as value,  value.value = patId,  identifier.system as idsystem,  idsystem.value = 'http://www.example.ch/patienteniddomain',  identifier.type as type,  type.coding as coding,  coding.system as system,  system.value = 'http://terminology.hl7.org/CodeSystem/v2-0203',  coding.code as code,  code.value = 'MR' "R22PatientPIDPatientID";
  } "patientID";
  // <!-- 2.2 Patient.PID (PatientID) -->
  // <identifier>
  // <type>
  // <coding>
  // <system value="http://terminology.hl7.org/CodeSystem/v2-0203" />
  // <code value="MR" />
  // <display value="Medical record number"/>
  // </coding>
  // </type>
  // ISSUE8: what do with system value
  // <system value="http://www.example.ch/patienteniddomain"/>
  // <value value="Patienten-ID"/>
  // </identifier>//
  visit where (visit.PatientName or visit.PatientGivenName) -> patient.name as name then ServiceToPatientName(visit, name) "ServiceToPatient";
  visit.PatientGender as gender then {
    gender.data as v -> patient.gender = translate(v, '#gender', 'code') "gender";
  } "R26PatientGeschlechtPatientGender";
  visit.PatientBirthDate as birthDate then {
    birthDate.data as v -> patient.birthDate = v "birthDate";
  } "R25PatientGebDatumPatientBirthDate";
}

group DiagnosisToCondition(source diagnosis : Diagnosis, target cond : Condition) {
  diagnosis ->  cond.subject = create('Reference') as ref,  ref.reference = '#pat' "containedpatient";
  // * Identifier 0..1 http://fhir.ch/ig/ch-alis/StructureDefinition/Text "TODO"
  diagnosis.Identifier as identifier then {
    identifier.data as data ->  cond.identifier as identifier,  identifier.value = data "identifier";
  };
  diagnosis.Code as code ->  cond.code = create('CodeableConcept') as cc,  cc.coding = create('Coding') as coding,  coding.code = (%code.data),  coding.display = (%diagnosis.Display.data) then {
    diagnosis.Category as category then {
      category.data as data where (startsWith('ICD')) -> coding.system = 'http://hl7.org/fhir/sid/icd-10';
    } "serviceType";
  } "R316ProzedurcodeCode";
  // TODO system is not yet correct
  diagnosis.OnsetDateTime as onsetDateTime -> cond.onset = (%onsetDateTime.data) "onsetDateTime";
  diagnosis.Laterality as laterality then {
    laterality.data as v ->  cond.bodySite = create('CodeableConcept') as cc,  cc.coding = create('Coding') as coding,  coding.code = translate(v, '#laterality', 'code'),  coding.system = 'http://snomed.info/sct',  coding.display = (%diagnosis.LateralityDisplay.data) "R318SeiteLaterality";
  } "laterality";
}

group DiagGroupToCondition(source diagGroup : DiagGroup, target cond : Condition) {
  diagGroup ->  cond.subject = create('Reference') as ref,  ref.reference = '#pat' "containedpatient";
  diagGroup.DiagCode as data ->  cond.code = create('CodeableConcept') as cc,  cc.coding = create('Coding') as coding,  coding.code = data then {
    diagGroup.DiagCatType as diagCatType then {
      diagCatType.data as data -> coding.system = translate(data, '#serviceMap', 'code') "R293KatalogtypDiagCatType";
    } "serviceType";
  } "R291DiagnosecodeDiagCode";
}

group TerminationToExtension(source visit : Visit, target ext : Extension) {
  visit.TerminationVisit as visit then {
    visit.data as data ->  ext.extension as ext1,  ext1.url = 'TerminationVisit',  ext1.value = create('date') as date,  date.value = data "R27FallAbschlussTerminationVisit";
  };
  visit.TerminationReason as visit then {
    visit.data as data ->  ext.extension as ext1,  ext1.url = 'TerminationReason',  ext1.value = create('string') as string,  string.value = data "R28FallAbschlussgrundTerminationReason";
  } "TerminationVisit";
}

group VisitToEncounter(source visit : Visit, target encounter : Encounter) {
  visit where (visit.TerminationVisit or visit.TerminationReason) ->  encounter.extension as ext,  ext.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-termination' then TerminationToExtension(visit, ext) "TerminationToExtension";
  visit.VisitNumber as visitNumber then {
    // ISSUE8: what to do with falldomain? <system value="http://www.example.ch/fallnummerdomain"/>
    visitNumber.data as data ->  encounter.identifier = create('Identifier') as identifier,  identifier.value as value,  value.value = data,  identifier.system as idsystem,  idsystem.value = 'http://www.example.ch/fallnummerdomain',  identifier.type as type,  type.coding as coding,  coding.system as system,  system.value = 'http://terminology.hl7.org/CodeSystem/v2-0203',  coding.code as code,  code.value = 'VN' "R21FallVisitNumber";
  } "encounterID";
  visit -> encounter.status = 'finished' "Finished";
  visit ->  encounter.class as coding,  coding.system as system,  system.value = 'http://terminology.hl7.org/CodeSystem/v3-ActCode',  coding.code as code,  code.value = 'IMP',  coding.display as display,  display.value = 'inpatient encounter' "R21FallVisitNumber";
  visit ->  encounter.subject = create('Reference') as ref,  ref.reference = '#pat' "subject";
  visit.DiagGroup as diaggroup ->  encounter.diagnosis as diag,  diag.condition = create('Reference') as ref,  ref.reference = '#cond' then {
    diaggroup.DiagType as diagType ->  diag.use as use,  use.text = (%diagType.data) "R292DiagnosetypDiagType";
  } "R29DiagnoseGruppeDiagGroup";
}


Source

{
  "resourceType" : "StructureMap",
  "id" : "Alis43ToBundle",
  "meta" : {
    "lastUpdated" : "2024-05-01T13:40:44.080+00:00"
  },
  "text" : {
    "status" : "generated",
    "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n <pre>/// url = &quot;http://fhir.ch/ig/ch-alis/StructureMap/Alis43ToBundle&quot;\n/// name = &quot;Alis43ToBundle&quot;\n/// title = &quot;null&quot;\n/// status = &quot;draft&quot;\n\n// Convert ALIS43 XML to a Bundle according to the CH ALIS implmementation guide,\n// 2020-12-03 by Oliver Egger, copyright ahdis ag, Apache License,\n// FHIR: http://hl7.org/fhir/r4/.\n// ISSUE7: what are the URL's oid's we have to define.\n\nconceptmap &quot;serviceMap&quot; {\n prefix s = &quot;http://fhir.ch/ig/ch-alis&quot;\n prefix t = &quot;http://hl7.org/fhir&quot;\n\n s:TARMED == t:&quot;urn:oid:2.16.756.5.30.1.129.1.4&quot;\n s:ICD10 == t:&quot;urn:oid:2.16.756.5.30.1.126.3.2&quot;\n}\n\nconceptmap &quot;gender&quot; {\n prefix s = &quot;http://fhir.ch/ig/ch-alis&quot;\n prefix t = &quot;http://hl7.org/fhir/ValueSet/administrative-gender&quot;\n\n s:M == t:male\n s:F == t:female\n}\n\nconceptmap &quot;laterality&quot; {\n prefix s = &quot;http://fhir.ch/ig/ch-alis&quot;\n prefix t = &quot;http://snomed.info/sct&quot;\n\n s:l == t:&quot;7771000&quot;\n s:r == t:&quot;24028007&quot;\n s:b == t:&quot;51440002&quot;\n}\n\nuses &quot;http://fhir.ch/ig/ch-alis/StructureDefinition/Header&quot; alias Header as source\nuses &quot;http://fhir.ch/ig/ch-alis/StructureDefinition/Visit&quot; alias Visit as source\nuses &quot;http://fhir.ch/ig/ch-alis/StructureDefinition/Service&quot; alias Service as source\nuses &quot;http://fhir.ch/ig/ch-alis/StructureDefinition/PersonV40&quot; alias PersonV40 as source\nuses &quot;http://fhir.ch/ig/ch-alis/StructureDefinition/ParameterV40&quot; alias ParameterV40 as source\nuses &quot;http://fhir.ch/ig/ch-alis/StructureDefinition/DiagGroup&quot; alias DiagGroup as source\nuses &quot;http://fhir.ch/ig/ch-alis/StructureDefinition/LeistungsschnittstelleProcedure&quot; alias Proc as source\nuses &quot;http://fhir.ch/ig/ch-alis/StructureDefinition/Diagnosis&quot; alias Diagnosis as source\nuses &quot;http://hl7.org/fhir/StructureDefinition/Bundle&quot; alias Bundle as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/ChargeItem&quot; alias ChargeItem as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/Extension&quot; alias Extension as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/MessageHeader&quot; alias MessageHeader as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/BackboneElement&quot; alias BackboneElement as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/HumanName&quot; alias HumanName as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/Condition&quot; alias Condition as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/Encounter&quot; alias Encounter as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/Procedure&quot; alias Procedure as target\n\ngroup Alis43ToBundle(source header : Header, target bundle : Bundle) {\n header -&gt; bundle.meta as meta, meta.profile as profile, profile.value = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-message', bundle.entry as e, e.resource = create('MessageHeader') as messageHeader, messageHeader.id = uuid() as uuid, e.fullUrl = append('urn:uuid:', uuid), bundle.entry as e2, e2.resource = create('Bundle') as transactionBundle, transactionBundle.id = uuid() as uuid2, e2.fullUrl = append('urn:uuid:', uuid2), messageHeader.focus = create('Reference') as reference, reference.type = 'Bundle', reference.reference = append('urn:uuid:', uuid2) then {\n header then Alis43ToMessageHeader(header, messageHeader) &quot;messageHeader&quot;;\n header then Alis43ToBundleTransaction(header, transactionBundle) &quot;bundleTransaction&quot;;\n } &quot;bundle&quot;;\n header -&gt; bundle.type = 'message' &quot;type&quot;;\n header.FileCreationDate as fileCreationDate then {\n fileCreationDate.data as date -&gt; bundle.timestamp = date &quot;date&quot;;\n };\n}\n\ngroup Alis43ToMessageHeader(source header : Header, target messageHeader : MessageHeader) {\n // ISSUE1: should be link to a MessageDefinition or a code?\n header -&gt; messageHeader.event = create('uri') as value, value.value = 'http://fhir.ch/ig/ch-alis-43' &quot;eventUri&quot;;\n // ISSUE2: MessageControlID cannot be id of entry, needs to be either fullUrl oder uuid, need to map this to an identifier\n header -&gt; messageHeader.source as source then {\n header.SoftwareReleaseNumber as version -&gt; source.version = (%version.data) &quot;version&quot;;\n // ISSUE3: &quot; : &quot;urn:SendingApplication:SendingFacility:SendingServiceCode&quot; -&gt; add urn: in example/docu\n header -&gt; source.endpoint = ('urn:' + %header.SendingApplication.data + ':' + %header.SendingFacility.data + ':' + %header.SendingServiceCode.data) &quot;endpoint&quot;;\n } &quot;source&quot;;\n header -&gt; messageHeader.destination as destination then {\n // ISSUE4: &quot; : &quot;urn:ReceivingApplication, ReceivingFacility, ReceivingServiceCode&quot; -&gt; add urn: in example/docu\n header -&gt; destination.endpoint = ('urn:' + %header.ReceivingApplication.data + ':' + %header.ReceivingFacility.data + ':' + %header.ReceivingServiceCode.data) &quot;endpoint&quot;;\n } &quot;destination&quot;;\n}\n\ngroup Alis43ToBundleTransaction(source header : Header, target transactionBundle : Bundle) {\n header -&gt; transactionBundle.type = 'transaction' &quot;transaction&quot;;\n header.Visit as visit then {\n visit.Service as service -&gt; transactionBundle.entry as e, e.resource = create('ChargeItem') as chargeItem then ServiceToChargeItem(service, visit, chargeItem, e) &quot;ServiceToChargeItem&quot;;\n };\n}\n\ngroup ServiceToChargeItem(source service : Service, source visit : Visit, target chargeItem : ChargeItem, target entry) {\n service.ItemNumber as itemNumber -&gt; chargeItem.id = (%itemNumber.data.lower()) as uuid, entry.fullUrl = append('urn:uuid:', uuid) &quot;R311LaufnummerItemNumber&quot;;\n service -&gt; chargeItem.contained = create('Patient') as patient, patient.id = 'pat' as containedid, chargeItem.subject = create('Reference') as ref, ref.reference = ('#' + %containedid) then ServiceToPatient(service, visit, patient) &quot;patient&quot;;\n visit -&gt; chargeItem.contained = create('Encounter') as encounter, encounter.id = 'enc' as containedid, chargeItem.context = create('Reference') as ref, ref.reference = ('#' + %containedid) then {\n visit then VisitToEncounter(visit, encounter) &quot;VisitToEncounter&quot;;\n service.Diagnosis as diag -&gt; chargeItem.contained = create('Condition') as condition, condition.id = uuid() as containedid, encounter.diagnosis as diag, diag.condition = create('Reference') as ref, ref.reference = ('#' + %containedid) then DiagnosisToCondition(diag, condition) &quot;DiagnosisToCondition&quot;;\n } &quot;encounter&quot;;\n visit.DiagGroup as diaggroup -&gt; chargeItem.contained = create('Condition') as cond, cond.id = 'cond' as containedid then DiagGroupToCondition(diaggroup, cond) &quot;DiagGroupToCondition&quot;;\n service where (service.Transaction.exists() = false) -&gt; entry.request as request, request.method = 'POST', request.url = 'ChargeItem' &quot;POSTDEFAULT&quot;;\n service.Transaction where (service.Transaction = 'insert') -&gt; entry.request as request, request.method = 'POST', request.url = 'ChargeItem' &quot;POST&quot;;\n service.Transaction where (service.Transaction = 'update') -&gt; entry.request as request, request.method = 'PUT', request.url = 'ChargeItem' &quot;UPDATE&quot;;\n service.Transaction where (service.Transaction = 'delete') -&gt; entry.request as request, request.method = 'DELETE', request.url = 'ChargeItem' &quot;DELETE&quot;;\n service.SessionID as sessionID -&gt; chargeItem.extension as extension, extension.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-sessionid', extension.value = create('string') as value, value.value = (%sessionID.data) &quot;R32SitzungSessionID&quot;;\n service.OrderID as orderID -&gt; chargeItem.extension as extension, extension.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-orderid', extension.value = create('string') as value, value.value = (%orderID.data) &quot;R33AuftragsnummerOrderID&quot;;\n service.OrderDate as orderDate -&gt; chargeItem.extension as extension, extension.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-orderdate', extension.value = create('dateTime') as value, value.value = (%orderDate.data) &quot;R33AuftragsnummerOrderID&quot;;\n service.Form as form -&gt; chargeItem.extension as extension, extension.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-form', extension.value = create('string') as value, value.value = (%form.data) &quot;R37FormularbezeichnungForm&quot;;\n service.ParameterV40 as parameterV40 -&gt; chargeItem.extension as extension, extension.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-parameterv40' then ParameterV40ToExtension(parameterV40, extension) &quot;R4ParamterV40ParameterV40&quot;;\n service -&gt; chargeItem.status = 'billable' &quot;billable&quot;;\n service.RefItemNumber as refItemNumber then {\n refItemNumber.data as data -&gt; chargeItem.partOf = create('Reference') as ref, ref.reference = ('urn:uuid:' + %data.lower()), ref.type = 'ChargeItem' &quot;R312ReferenzzuHauptleistungRefItemNumber&quot;;\n };\n service.ServiceItem as serviceItem then {\n serviceItem.data as data -&gt; chargeItem.code = create('CodeableConcept') as cc, cc.coding = create('Coding') as coding, coding.code = data then {\n service.ServiceType as serviceType then {\n serviceType.data as data -&gt; coding.system = translate(data, '#serviceMap', 'code') &quot;R35KatalogServiceType&quot;;\n } &quot;servicType&quot;;\n } &quot;R36TarifpositionServiceItem&quot;;\n } &quot;R36Tarifposition&quot;;\n service.ServiceDate as serviceData -&gt; chargeItem.occurrence = create('dateTime') as occurrence, occurrence.value = (%serviceData.data) &quot;R31LeistungsdatumServiceDate&quot;;\n service.PersonV40 as personV40 -&gt; chargeItem.performer = create('BackboneElement') as performer then PersonV40ToPerformer(personV40, performer) &quot;R315PersonV40PersonV40&quot;;\n service.ProviderID as providerID -&gt; chargeItem.performingOrganization = create('Reference') as reference, reference.display = (%providerID.data) &quot;R39ErbringendeOrganizationProviderID&quot;;\n service.ReferrerID as referrerID -&gt; chargeItem.costCenter = create('Reference') as reference, reference.display = (%referrerID.data) &quot;R34AuftraggebendeKostenstelleReferrerID&quot;;\n service.Quantity as quantity -&gt; chargeItem.quantity = create('Quantity') as q, q.value as value, value.value = (%quantity.data) &quot;R313AnzahlQuantity&quot;;\n service.EnteredBy as enteredBy -&gt; chargeItem.enterer = create('Reference') as reference, reference.display = (%enteredBy.data) &quot;R310ErfasserEnteredBy&quot;;\n service.EnteredDateTime as enteredDateTime -&gt; chargeItem.enteredDate = create('dateTime') as enteredDate, enteredDate.value = (%enteredDateTime.data) &quot;R38ErfassungsdatumEnteredDateTime&quot;;\n service.PatientContactID as patientContactID then {\n patientContactID.data as data -&gt; chargeItem.identifier = create('Identifier') as identifier, identifier.value = data &quot;PatientContactID&quot;;\n } &quot;patientContactID&quot;;\n service.Costweight as costweight then {\n costweight.data as data -&gt; chargeItem.factorOverride = data &quot;Costweight&quot;;\n } &quot;costweight&quot;;\n service.Procedure as proc -&gt; chargeItem.contained = create('Procedure') as procedure, procedure.id = uuid() as containedid, chargeItem.service = create('Reference') as service, service.reference = ('#' + %containedid) then ServiceProcedureToFhirProcedure(proc, procedure) &quot;ServiceProcedureToFhirProcedure&quot;;\n}\n\ngroup ServiceProcedureToFhirProcedure(source proc : Proc, target procedure : Procedure) {\n proc.Identifier as identifier -&gt; procedure.identifier = create('Identifier') as identifier, identifier.value = (%identifier.data) &quot;R314ProzedurIDIdentifier&quot;;\n proc.Code as chopcode where (%proc.Category.data = 'CHOP_2023') -&gt; procedure.code = create('CodeableConcept') as cc, cc.coding = create('Coding') as coding, coding.code = (%chopcode.data), coding.system = 'https://www.bfs.admin.ch/bfs/statistiche/catalog/chop2023', coding.display = (%proc.Display.data) &quot;R316ProzedurcodeCode&quot;;\n proc.PerformedDateTime as performedDateTime -&gt; procedure.performed = (%performedDateTime.data) &quot;R317DatumZeitPerformedDateTime&quot;;\n proc.Laterality as laterality then {\n laterality.data as v -&gt; procedure.bodySite = create('CodeableConcept') as cc, cc.coding = create('Coding') as coding, coding.code = translate(v, '#laterality', 'code'), coding.system = 'http://snomed.info/sct', coding.display = (%proc.LateralityDisplay.data) &quot;R318SeiteLaterality&quot;;\n } &quot;laterality&quot;;\n proc.Performer as performer then {\n // TODO Perfomer.function\n performer.Identifier as identifier then {\n identifier.data as data -&gt; procedure.performer as performer, performer.actor as actor, actor.identifier as identifier, identifier.value = data &quot;identifier&quot;;\n };\n } &quot;performer&quot;;\n proc -&gt; procedure.subject = create('Reference') as ref, ref.reference = '#pat' &quot;containedpatient&quot;;\n proc -&gt; procedure.status = 'completed' &quot;status&quot;;\n}\n\ngroup PersonV40ToPerformer(source personV40 : PersonV40, target performer) {\n personV40.PersonTyp as personTyp -&gt; performer.function as cc, cc.coding as coding, coding.system as system, system.value = 'http://fhir.ch/ig/ch-alis/CodeSystem/ch-alis-persontyp', coding.code as code, code.value = personTyp &quot;R3152PersonIDPersonID&quot;;\n personV40.PersonID as personId -&gt; performer.actor = create('Reference') as reference, reference.display = (%personId.data) &quot;R3152PersonIDPersonID&quot;;\n}\n\ngroup ParameterV40ToExtension(source parameterV40 : ParameterV40, target extension : Extension) {\n parameterV40.ParamTyp as paramTyp -&gt; extension.extension as extInner then InnerExtensionParamTyp(paramTyp, extInner);\n parameterV40.ParamValue as paramValue then {\n paramValue.data as data -&gt; extension.extension as extInner then InnerExtensionParamValue(data, extInner);\n };\n}\n\ngroup InnerExtensionParamTyp(source src, target ext : Extension) {\n src -&gt; ext.url = 'ParamTyp' &quot;url&quot;;\n src -&gt; ext.value = create('CodeableConcept') as cc, cc.text as text, text.value = src &quot;string&quot;;\n}\n\ngroup InnerExtensionParamValue(source src, target ext : Extension) {\n src -&gt; ext.url = 'ParamValue' &quot;url&quot;;\n src -&gt; ext.value = create('string') as string, string.value = src &quot;string&quot;;\n}\n\ngroup ServiceToPatientName(source visit : Visit, target name : HumanName) {\n visit.PatientName as patientName then {\n patientName.data as data -&gt; name.family = data &quot;R23PatientNamePatientName&quot;;\n } &quot;patientName&quot;;\n visit.PatientGivenName as patientGivenName then {\n patientGivenName.data as data -&gt; name.given = data &quot;R24PatientVornamePatientGivenName&quot;;\n } &quot;patientGivenName&quot;;\n}\n\ngroup ServiceToPatient(source service : Service, source visit : Visit, target patient : Patient) {\n visit.PatientID as patientID then {\n patientID.data as patId -&gt; patient.identifier as identifier, identifier.value as value, value.value = patId, identifier.system as idsystem, idsystem.value = 'http://www.example.ch/patienteniddomain', identifier.type as type, type.coding as coding, coding.system as system, system.value = 'http://terminology.hl7.org/CodeSystem/v2-0203', coding.code as code, code.value = 'MR' &quot;R22PatientPIDPatientID&quot;;\n } &quot;patientID&quot;;\n // &lt;!-- 2.2 Patient.PID (PatientID) --&gt;\n // &lt;identifier&gt;\n // &lt;type&gt;\n // &lt;coding&gt;\n // &lt;system value=&quot;http://terminology.hl7.org/CodeSystem/v2-0203&quot; /&gt;\n // &lt;code value=&quot;MR&quot; /&gt;\n // &lt;display value=&quot;Medical record number&quot;/&gt;\n // &lt;/coding&gt;\n // &lt;/type&gt;\n // ISSUE8: what do with system value\n // &lt;system value=&quot;http://www.example.ch/patienteniddomain&quot;/&gt;\n // &lt;value value=&quot;Patienten-ID&quot;/&gt;\n // &lt;/identifier&gt;//\n visit where (visit.PatientName or visit.PatientGivenName) -&gt; patient.name as name then ServiceToPatientName(visit, name) &quot;ServiceToPatient&quot;;\n visit.PatientGender as gender then {\n gender.data as v -&gt; patient.gender = translate(v, '#gender', 'code') &quot;gender&quot;;\n } &quot;R26PatientGeschlechtPatientGender&quot;;\n visit.PatientBirthDate as birthDate then {\n birthDate.data as v -&gt; patient.birthDate = v &quot;birthDate&quot;;\n } &quot;R25PatientGebDatumPatientBirthDate&quot;;\n}\n\ngroup DiagnosisToCondition(source diagnosis : Diagnosis, target cond : Condition) {\n diagnosis -&gt; cond.subject = create('Reference') as ref, ref.reference = '#pat' &quot;containedpatient&quot;;\n // * Identifier 0..1 http://fhir.ch/ig/ch-alis/StructureDefinition/Text &quot;TODO&quot;\n diagnosis.Identifier as identifier then {\n identifier.data as data -&gt; cond.identifier as identifier, identifier.value = data &quot;identifier&quot;;\n };\n diagnosis.Code as code -&gt; cond.code = create('CodeableConcept') as cc, cc.coding = create('Coding') as coding, coding.code = (%code.data), coding.display = (%diagnosis.Display.data) then {\n diagnosis.Category as category then {\n category.data as data where (startsWith('ICD')) -&gt; coding.system = 'http://hl7.org/fhir/sid/icd-10';\n } &quot;serviceType&quot;;\n } &quot;R316ProzedurcodeCode&quot;;\n // TODO system is not yet correct\n diagnosis.OnsetDateTime as onsetDateTime -&gt; cond.onset = (%onsetDateTime.data) &quot;onsetDateTime&quot;;\n diagnosis.Laterality as laterality then {\n laterality.data as v -&gt; cond.bodySite = create('CodeableConcept') as cc, cc.coding = create('Coding') as coding, coding.code = translate(v, '#laterality', 'code'), coding.system = 'http://snomed.info/sct', coding.display = (%diagnosis.LateralityDisplay.data) &quot;R318SeiteLaterality&quot;;\n } &quot;laterality&quot;;\n}\n\ngroup DiagGroupToCondition(source diagGroup : DiagGroup, target cond : Condition) {\n diagGroup -&gt; cond.subject = create('Reference') as ref, ref.reference = '#pat' &quot;containedpatient&quot;;\n diagGroup.DiagCode as data -&gt; cond.code = create('CodeableConcept') as cc, cc.coding = create('Coding') as coding, coding.code = data then {\n diagGroup.DiagCatType as diagCatType then {\n diagCatType.data as data -&gt; coding.system = translate(data, '#serviceMap', 'code') &quot;R293KatalogtypDiagCatType&quot;;\n } &quot;serviceType&quot;;\n } &quot;R291DiagnosecodeDiagCode&quot;;\n}\n\ngroup TerminationToExtension(source visit : Visit, target ext : Extension) {\n visit.TerminationVisit as visit then {\n visit.data as data -&gt; ext.extension as ext1, ext1.url = 'TerminationVisit', ext1.value = create('date') as date, date.value = data &quot;R27FallAbschlussTerminationVisit&quot;;\n };\n visit.TerminationReason as visit then {\n visit.data as data -&gt; ext.extension as ext1, ext1.url = 'TerminationReason', ext1.value = create('string') as string, string.value = data &quot;R28FallAbschlussgrundTerminationReason&quot;;\n } &quot;TerminationVisit&quot;;\n}\n\ngroup VisitToEncounter(source visit : Visit, target encounter : Encounter) {\n visit where (visit.TerminationVisit or visit.TerminationReason) -&gt; encounter.extension as ext, ext.url = 'http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-termination' then TerminationToExtension(visit, ext) &quot;TerminationToExtension&quot;;\n visit.VisitNumber as visitNumber then {\n // ISSUE8: what to do with falldomain? &lt;system value=&quot;http://www.example.ch/fallnummerdomain&quot;/&gt;\n visitNumber.data as data -&gt; encounter.identifier = create('Identifier') as identifier, identifier.value as value, value.value = data, identifier.system as idsystem, idsystem.value = 'http://www.example.ch/fallnummerdomain', identifier.type as type, type.coding as coding, coding.system as system, system.value = 'http://terminology.hl7.org/CodeSystem/v2-0203', coding.code as code, code.value = 'VN' &quot;R21FallVisitNumber&quot;;\n } &quot;encounterID&quot;;\n visit -&gt; encounter.status = 'finished' &quot;Finished&quot;;\n visit -&gt; encounter.class as coding, coding.system as system, system.value = 'http://terminology.hl7.org/CodeSystem/v3-ActCode', coding.code as code, code.value = 'IMP', coding.display as display, display.value = 'inpatient encounter' &quot;R21FallVisitNumber&quot;;\n visit -&gt; encounter.subject = create('Reference') as ref, ref.reference = '#pat' &quot;subject&quot;;\n visit.DiagGroup as diaggroup -&gt; encounter.diagnosis as diag, diag.condition = create('Reference') as ref, ref.reference = '#cond' then {\n diaggroup.DiagType as diagType -&gt; diag.use as use, use.text = (%diagType.data) &quot;R292DiagnosetypDiagType&quot;;\n } &quot;R29DiagnoseGruppeDiagGroup&quot;;\n}\n\n</pre>\n </div>"
  },
  "contained" : [
    {
      "resourceType" : "ConceptMap",
      "id" : "serviceMap",
      "status" : "draft",
      "group" : [
        {
          "source" : "http://fhir.ch/ig/ch-alis",
          "target" : "http://hl7.org/fhir",
          "element" : [
            {
              "code" : "TARMED",
              "target" : [
                {
                  "code" : "urn:oid:2.16.756.5.30.1.129.1.4",
                  "equivalence" : "equivalent"
                }
              ]
            },
            {
              "code" : "ICD10",
              "target" : [
                {
                  "code" : "urn:oid:2.16.756.5.30.1.126.3.2",
                  "equivalence" : "equivalent"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "resourceType" : "ConceptMap",
      "id" : "gender",
      "status" : "draft",
      "group" : [
        {
          "source" : "http://fhir.ch/ig/ch-alis",
          "target" : "http://hl7.org/fhir/ValueSet/administrative-gender",
          "element" : [
            {
              "code" : "M",
              "target" : [
                {
                  "code" : "male",
                  "equivalence" : "equivalent"
                }
              ]
            },
            {
              "code" : "F",
              "target" : [
                {
                  "code" : "female",
                  "equivalence" : "equivalent"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "resourceType" : "ConceptMap",
      "id" : "laterality",
      "status" : "draft",
      "group" : [
        {
          "source" : "http://fhir.ch/ig/ch-alis",
          "target" : "http://snomed.info/sct",
          "element" : [
            {
              "code" : "l",
              "target" : [
                {
                  "code" : "7771000",
                  "equivalence" : "equivalent"
                }
              ]
            },
            {
              "code" : "r",
              "target" : [
                {
                  "code" : "24028007",
                  "equivalence" : "equivalent"
                }
              ]
            },
            {
              "code" : "b",
              "target" : [
                {
                  "code" : "51440002",
                  "equivalence" : "equivalent"
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "url" : "http://fhir.ch/ig/ch-alis/StructureMap/Alis43ToBundle",
  "version" : "0.3.0",
  "name" : "Alis43ToBundle",
  "status" : "draft",
  "date" : "2024-10-29T15:42:46+00:00",
  "publisher" : "ALIS-Connect",
  "contact" : [
    {
      "name" : "ALIS-Connect",
      "telecom" : [
        {
          "system" : "url",
          "value" : "https://www.alis-connect.ch/"
        }
      ]
    }
  ],
  "description" : "Convert ALIS43 XML to a Bundle according to the CH ALIS implmementation guide,\r\n2020-12-03 by Oliver Egger, copyright ahdis ag, Apache License,\r\nFHIR: http://hl7.org/fhir/r4/.\r\nISSUE7: what are the URL's oid's we have to define.",
  "jurisdiction" : [
    {
      "coding" : [
        {
          "system" : "urn:iso:std:iso:3166",
          "code" : "CH"
        }
      ]
    }
  ],
  "copyright" : "not-open-source",
  "structure" : [
    {
      "url" : "http://fhir.ch/ig/ch-alis/StructureDefinition/Header",
      "mode" : "source",
      "alias" : "Header"
    },
    {
      "url" : "http://fhir.ch/ig/ch-alis/StructureDefinition/Visit",
      "mode" : "source",
      "alias" : "Visit"
    },
    {
      "url" : "http://fhir.ch/ig/ch-alis/StructureDefinition/Service",
      "mode" : "source",
      "alias" : "Service"
    },
    {
      "url" : "http://fhir.ch/ig/ch-alis/StructureDefinition/PersonV40",
      "mode" : "source",
      "alias" : "PersonV40"
    },
    {
      "url" : "http://fhir.ch/ig/ch-alis/StructureDefinition/ParameterV40",
      "mode" : "source",
      "alias" : "ParameterV40"
    },
    {
      "url" : "http://fhir.ch/ig/ch-alis/StructureDefinition/DiagGroup",
      "mode" : "source",
      "alias" : "DiagGroup"
    },
    {
      "url" : "http://fhir.ch/ig/ch-alis/StructureDefinition/LeistungsschnittstelleProcedure",
      "mode" : "source",
      "alias" : "Proc"
    },
    {
      "url" : "http://fhir.ch/ig/ch-alis/StructureDefinition/Diagnosis",
      "mode" : "source",
      "alias" : "Diagnosis"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
      "mode" : "target",
      "alias" : "Bundle"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/ChargeItem",
      "mode" : "target",
      "alias" : "ChargeItem"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Extension",
      "mode" : "target",
      "alias" : "Extension"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/MessageHeader",
      "mode" : "target",
      "alias" : "MessageHeader"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/BackboneElement",
      "mode" : "target",
      "alias" : "BackboneElement"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/HumanName",
      "mode" : "target",
      "alias" : "HumanName"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Condition",
      "mode" : "target",
      "alias" : "Condition"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Encounter",
      "mode" : "target",
      "alias" : "Encounter"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Procedure",
      "mode" : "target",
      "alias" : "Procedure"
    }
  ],
  "group" : [
    {
      "name" : "Alis43ToBundle",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "header",
          "type" : "Header",
          "mode" : "source"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "bundle",
          "source" : [
            {
              "context" : "header"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "meta",
              "variable" : "meta"
            },
            {
              "context" : "meta",
              "contextType" : "variable",
              "element" : "profile",
              "variable" : "profile"
            },
            {
              "context" : "profile",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-message"
                }
              ]
            },
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "e"
            },
            {
              "context" : "e",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "messageHeader",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "MessageHeader"
                }
              ]
            },
            {
              "context" : "messageHeader",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "uuid",
              "transform" : "uuid"
            },
            {
              "context" : "e",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [
                {
                  "valueString" : "urn:uuid:"
                },
                {
                  "valueId" : "uuid"
                }
              ]
            },
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "e2"
            },
            {
              "context" : "e2",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "transactionBundle",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Bundle"
                }
              ]
            },
            {
              "context" : "transactionBundle",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "uuid2",
              "transform" : "uuid"
            },
            {
              "context" : "e2",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [
                {
                  "valueString" : "urn:uuid:"
                },
                {
                  "valueId" : "uuid2"
                }
              ]
            },
            {
              "context" : "messageHeader",
              "contextType" : "variable",
              "element" : "focus",
              "variable" : "reference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "type",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "Bundle"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "append",
              "parameter" : [
                {
                  "valueString" : "urn:uuid:"
                },
                {
                  "valueId" : "uuid2"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "messageHeader",
              "source" : [
                {
                  "context" : "header"
                }
              ],
              "dependent" : [
                {
                  "name" : "Alis43ToMessageHeader",
                  "variable" : [
                    "header",
                    "messageHeader"
                  ]
                }
              ]
            },
            {
              "name" : "bundleTransaction",
              "source" : [
                {
                  "context" : "header"
                }
              ],
              "dependent" : [
                {
                  "name" : "Alis43ToBundleTransaction",
                  "variable" : [
                    "header",
                    "transactionBundle"
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "type",
          "source" : [
            {
              "context" : "header"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "type",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "message"
                }
              ]
            }
          ]
        },
        {
          "name" : "FileCreationDate",
          "source" : [
            {
              "context" : "header",
              "element" : "FileCreationDate",
              "variable" : "fileCreationDate"
            }
          ],
          "rule" : [
            {
              "name" : "date",
              "source" : [
                {
                  "context" : "fileCreationDate",
                  "element" : "data",
                  "variable" : "date"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "timestamp",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "date"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "Alis43ToMessageHeader",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "header",
          "type" : "Header",
          "mode" : "source"
        },
        {
          "name" : "messageHeader",
          "type" : "MessageHeader",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "eventUri",
          "source" : [
            {
              "context" : "header"
            }
          ],
          "target" : [
            {
              "context" : "messageHeader",
              "contextType" : "variable",
              "element" : "event",
              "variable" : "value",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "uri"
                }
              ]
            },
            {
              "context" : "value",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "http://fhir.ch/ig/ch-alis-43"
                }
              ]
            }
          ]
        },
        {
          "name" : "source",
          "source" : [
            {
              "context" : "header"
            }
          ],
          "target" : [
            {
              "context" : "messageHeader",
              "contextType" : "variable",
              "element" : "source",
              "variable" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "version",
              "source" : [
                {
                  "context" : "header",
                  "element" : "SoftwareReleaseNumber",
                  "variable" : "version"
                }
              ],
              "target" : [
                {
                  "context" : "source",
                  "contextType" : "variable",
                  "element" : "version",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "%version.data"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "endpoint",
              "source" : [
                {
                  "context" : "header"
                }
              ],
              "target" : [
                {
                  "context" : "source",
                  "contextType" : "variable",
                  "element" : "endpoint",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'urn:' + %header.SendingApplication.data + ':' + %header.SendingFacility.data + ':' + %header.SendingServiceCode.data"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "destination",
          "source" : [
            {
              "context" : "header"
            }
          ],
          "target" : [
            {
              "context" : "messageHeader",
              "contextType" : "variable",
              "element" : "destination",
              "variable" : "destination"
            }
          ],
          "rule" : [
            {
              "name" : "endpoint",
              "source" : [
                {
                  "context" : "header"
                }
              ],
              "target" : [
                {
                  "context" : "destination",
                  "contextType" : "variable",
                  "element" : "endpoint",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'urn:' + %header.ReceivingApplication.data + ':' + %header.ReceivingFacility.data + ':' + %header.ReceivingServiceCode.data"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "Alis43ToBundleTransaction",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "header",
          "type" : "Header",
          "mode" : "source"
        },
        {
          "name" : "transactionBundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "transaction",
          "source" : [
            {
              "context" : "header"
            }
          ],
          "target" : [
            {
              "context" : "transactionBundle",
              "contextType" : "variable",
              "element" : "type",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "transaction"
                }
              ]
            }
          ]
        },
        {
          "name" : "Visit",
          "source" : [
            {
              "context" : "header",
              "element" : "Visit",
              "variable" : "visit"
            }
          ],
          "rule" : [
            {
              "name" : "ServiceToChargeItem",
              "source" : [
                {
                  "context" : "visit",
                  "element" : "Service",
                  "variable" : "service"
                }
              ],
              "target" : [
                {
                  "context" : "transactionBundle",
                  "contextType" : "variable",
                  "element" : "entry",
                  "variable" : "e"
                },
                {
                  "context" : "e",
                  "contextType" : "variable",
                  "element" : "resource",
                  "variable" : "chargeItem",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "ChargeItem"
                    }
                  ]
                }
              ],
              "dependent" : [
                {
                  "name" : "ServiceToChargeItem",
                  "variable" : [
                    "service",
                    "visit",
                    "chargeItem",
                    "e"
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "ServiceToChargeItem",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "service",
          "type" : "Service",
          "mode" : "source"
        },
        {
          "name" : "visit",
          "type" : "Visit",
          "mode" : "source"
        },
        {
          "name" : "chargeItem",
          "type" : "ChargeItem",
          "mode" : "target"
        },
        {
          "name" : "entry",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "R311LaufnummerItemNumber",
          "source" : [
            {
              "context" : "service",
              "element" : "ItemNumber",
              "variable" : "itemNumber"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "uuid",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%itemNumber.data.lower()"
                }
              ]
            },
            {
              "context" : "entry",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [
                {
                  "valueString" : "urn:uuid:"
                },
                {
                  "valueId" : "uuid"
                }
              ]
            }
          ]
        },
        {
          "name" : "patient",
          "source" : [
            {
              "context" : "service"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "contained",
              "variable" : "patient",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Patient"
                }
              ]
            },
            {
              "context" : "patient",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "containedid",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "pat"
                }
              ]
            },
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "subject",
              "variable" : "ref",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "ref",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'#' + %containedid"
                }
              ]
            }
          ],
          "dependent" : [
            {
              "name" : "ServiceToPatient",
              "variable" : [
                "service",
                "visit",
                "patient"
              ]
            }
          ]
        },
        {
          "name" : "encounter",
          "source" : [
            {
              "context" : "visit"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "contained",
              "variable" : "encounter",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Encounter"
                }
              ]
            },
            {
              "context" : "encounter",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "containedid",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "enc"
                }
              ]
            },
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "context",
              "variable" : "ref",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "ref",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'#' + %containedid"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "VisitToEncounter",
              "source" : [
                {
                  "context" : "visit"
                }
              ],
              "dependent" : [
                {
                  "name" : "VisitToEncounter",
                  "variable" : [
                    "visit",
                    "encounter"
                  ]
                }
              ]
            },
            {
              "name" : "DiagnosisToCondition",
              "source" : [
                {
                  "context" : "service",
                  "element" : "Diagnosis",
                  "variable" : "diag"
                }
              ],
              "target" : [
                {
                  "context" : "chargeItem",
                  "contextType" : "variable",
                  "element" : "contained",
                  "variable" : "condition",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Condition"
                    }
                  ]
                },
                {
                  "context" : "condition",
                  "contextType" : "variable",
                  "element" : "id",
                  "variable" : "containedid",
                  "transform" : "uuid"
                },
                {
                  "context" : "encounter",
                  "contextType" : "variable",
                  "element" : "diagnosis",
                  "variable" : "diag"
                },
                {
                  "context" : "diag",
                  "contextType" : "variable",
                  "element" : "condition",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                },
                {
                  "context" : "ref",
                  "contextType" : "variable",
                  "element" : "reference",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'#' + %containedid"
                    }
                  ]
                }
              ],
              "dependent" : [
                {
                  "name" : "DiagnosisToCondition",
                  "variable" : [
                    "diag",
                    "condition"
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "DiagGroupToCondition",
          "source" : [
            {
              "context" : "visit",
              "element" : "DiagGroup",
              "variable" : "diaggroup"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "contained",
              "variable" : "cond",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Condition"
                }
              ]
            },
            {
              "context" : "cond",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "containedid",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "cond"
                }
              ]
            }
          ],
          "dependent" : [
            {
              "name" : "DiagGroupToCondition",
              "variable" : [
                "diaggroup",
                "cond"
              ]
            }
          ]
        },
        {
          "name" : "POSTDEFAULT",
          "source" : [
            {
              "context" : "service",
              "condition" : "(service.Transaction.exists() = false)"
            }
          ],
          "target" : [
            {
              "context" : "entry",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "request"
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "method",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "POST"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "ChargeItem"
                }
              ]
            }
          ]
        },
        {
          "name" : "POST",
          "source" : [
            {
              "context" : "service",
              "element" : "Transaction",
              "condition" : "(service.Transaction = 'insert')"
            }
          ],
          "target" : [
            {
              "context" : "entry",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "request"
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "method",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "POST"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "ChargeItem"
                }
              ]
            }
          ]
        },
        {
          "name" : "UPDATE",
          "source" : [
            {
              "context" : "service",
              "element" : "Transaction",
              "condition" : "(service.Transaction = 'update')"
            }
          ],
          "target" : [
            {
              "context" : "entry",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "request"
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "method",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "PUT"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "ChargeItem"
                }
              ]
            }
          ]
        },
        {
          "name" : "DELETE",
          "source" : [
            {
              "context" : "service",
              "element" : "Transaction",
              "condition" : "(service.Transaction = 'delete')"
            }
          ],
          "target" : [
            {
              "context" : "entry",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "request"
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "method",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "DELETE"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "ChargeItem"
                }
              ]
            }
          ]
        },
        {
          "name" : "R32SitzungSessionID",
          "source" : [
            {
              "context" : "service",
              "element" : "SessionID",
              "variable" : "sessionID"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "extension",
              "variable" : "extension"
            },
            {
              "context" : "extension",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-sessionid"
                }
              ]
            },
            {
              "context" : "extension",
              "contextType" : "variable",
              "element" : "value",
              "variable" : "value",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "string"
                }
              ]
            },
            {
              "context" : "value",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%sessionID.data"
                }
              ]
            }
          ]
        },
        {
          "name" : "R33AuftragsnummerOrderID",
          "source" : [
            {
              "context" : "service",
              "element" : "OrderID",
              "variable" : "orderID"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "extension",
              "variable" : "extension"
            },
            {
              "context" : "extension",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-orderid"
                }
              ]
            },
            {
              "context" : "extension",
              "contextType" : "variable",
              "element" : "value",
              "variable" : "value",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "string"
                }
              ]
            },
            {
              "context" : "value",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%orderID.data"
                }
              ]
            }
          ]
        },
        {
          "name" : "R33AuftragsnummerOrderID",
          "source" : [
            {
              "context" : "service",
              "element" : "OrderDate",
              "variable" : "orderDate"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "extension",
              "variable" : "extension"
            },
            {
              "context" : "extension",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-orderdate"
                }
              ]
            },
            {
              "context" : "extension",
              "contextType" : "variable",
              "element" : "value",
              "variable" : "value",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "dateTime"
                }
              ]
            },
            {
              "context" : "value",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%orderDate.data"
                }
              ]
            }
          ]
        },
        {
          "name" : "R37FormularbezeichnungForm",
          "source" : [
            {
              "context" : "service",
              "element" : "Form",
              "variable" : "form"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "extension",
              "variable" : "extension"
            },
            {
              "context" : "extension",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-form"
                }
              ]
            },
            {
              "context" : "extension",
              "contextType" : "variable",
              "element" : "value",
              "variable" : "value",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "string"
                }
              ]
            },
            {
              "context" : "value",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%form.data"
                }
              ]
            }
          ]
        },
        {
          "name" : "R4ParamterV40ParameterV40",
          "source" : [
            {
              "context" : "service",
              "element" : "ParameterV40",
              "variable" : "parameterV40"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "extension",
              "variable" : "extension"
            },
            {
              "context" : "extension",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-parameterv40"
                }
              ]
            }
          ],
          "dependent" : [
            {
              "name" : "ParameterV40ToExtension",
              "variable" : [
                "parameterV40",
                "extension"
              ]
            }
          ]
        },
        {
          "name" : "billable",
          "source" : [
            {
              "context" : "service"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "status",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "billable"
                }
              ]
            }
          ]
        },
        {
          "name" : "RefItemNumber",
          "source" : [
            {
              "context" : "service",
              "element" : "RefItemNumber",
              "variable" : "refItemNumber"
            }
          ],
          "rule" : [
            {
              "name" : "R312ReferenzzuHauptleistungRefItemNumber",
              "source" : [
                {
                  "context" : "refItemNumber",
                  "element" : "data",
                  "variable" : "data"
                }
              ],
              "target" : [
                {
                  "context" : "chargeItem",
                  "contextType" : "variable",
                  "element" : "partOf",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                },
                {
                  "context" : "ref",
                  "contextType" : "variable",
                  "element" : "reference",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'urn:uuid:' + %data.lower()"
                    }
                  ]
                },
                {
                  "context" : "ref",
                  "contextType" : "variable",
                  "element" : "type",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "ChargeItem"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "R36Tarifposition",
          "source" : [
            {
              "context" : "service",
              "element" : "ServiceItem",
              "variable" : "serviceItem"
            }
          ],
          "rule" : [
            {
              "name" : "R36TarifpositionServiceItem",
              "source" : [
                {
                  "context" : "serviceItem",
                  "element" : "data",
                  "variable" : "data"
                }
              ],
              "target" : [
                {
                  "context" : "chargeItem",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "cc",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "CodeableConcept"
                    }
                  ]
                },
                {
                  "context" : "cc",
                  "contextType" : "variable",
                  "element" : "coding",
                  "variable" : "coding",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Coding"
                    }
                  ]
                },
                {
                  "context" : "coding",
                  "contextType" : "variable",
                  "element" : "code",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "data"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "servicType",
                  "source" : [
                    {
                      "context" : "service",
                      "element" : "ServiceType",
                      "variable" : "serviceType"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "R35KatalogServiceType",
                      "source" : [
                        {
                          "context" : "serviceType",
                          "element" : "data",
                          "variable" : "data"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "translate",
                          "parameter" : [
                            {
                              "valueId" : "data"
                            },
                            {
                              "valueString" : "#serviceMap"
                            },
                            {
                              "valueString" : "code"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "R31LeistungsdatumServiceDate",
          "source" : [
            {
              "context" : "service",
              "element" : "ServiceDate",
              "variable" : "serviceData"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "occurrence",
              "variable" : "occurrence",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "dateTime"
                }
              ]
            },
            {
              "context" : "occurrence",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%serviceData.data"
                }
              ]
            }
          ]
        },
        {
          "name" : "R315PersonV40PersonV40",
          "source" : [
            {
              "context" : "service",
              "element" : "PersonV40",
              "variable" : "personV40"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "performer",
              "variable" : "performer",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "BackboneElement"
                }
              ]
            }
          ],
          "dependent" : [
            {
              "name" : "PersonV40ToPerformer",
              "variable" : [
                "personV40",
                "performer"
              ]
            }
          ]
        },
        {
          "name" : "R39ErbringendeOrganizationProviderID",
          "source" : [
            {
              "context" : "service",
              "element" : "ProviderID",
              "variable" : "providerID"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "performingOrganization",
              "variable" : "reference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "display",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%providerID.data"
                }
              ]
            }
          ]
        },
        {
          "name" : "R34AuftraggebendeKostenstelleReferrerID",
          "source" : [
            {
              "context" : "service",
              "element" : "ReferrerID",
              "variable" : "referrerID"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "costCenter",
              "variable" : "reference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "display",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%referrerID.data"
                }
              ]
            }
          ]
        },
        {
          "name" : "R313AnzahlQuantity",
          "source" : [
            {
              "context" : "service",
              "element" : "Quantity",
              "variable" : "quantity"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "quantity",
              "variable" : "q",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Quantity"
                }
              ]
            },
            {
              "context" : "q",
              "contextType" : "variable",
              "element" : "value",
              "variable" : "value"
            },
            {
              "context" : "value",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%quantity.data"
                }
              ]
            }
          ]
        },
        {
          "name" : "R310ErfasserEnteredBy",
          "source" : [
            {
              "context" : "service",
              "element" : "EnteredBy",
              "variable" : "enteredBy"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "enterer",
              "variable" : "reference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "display",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%enteredBy.data"
                }
              ]
            }
          ]
        },
        {
          "name" : "R38ErfassungsdatumEnteredDateTime",
          "source" : [
            {
              "context" : "service",
              "element" : "EnteredDateTime",
              "variable" : "enteredDateTime"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "enteredDate",
              "variable" : "enteredDate",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "dateTime"
                }
              ]
            },
            {
              "context" : "enteredDate",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%enteredDateTime.data"
                }
              ]
            }
          ]
        },
        {
          "name" : "patientContactID",
          "source" : [
            {
              "context" : "service",
              "element" : "PatientContactID",
              "variable" : "patientContactID"
            }
          ],
          "rule" : [
            {
              "name" : "PatientContactID",
              "source" : [
                {
                  "context" : "patientContactID",
                  "element" : "data",
                  "variable" : "data"
                }
              ],
              "target" : [
                {
                  "context" : "chargeItem",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Identifier"
                    }
                  ]
                },
                {
                  "context" : "identifier",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "data"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "costweight",
          "source" : [
            {
              "context" : "service",
              "element" : "Costweight",
              "variable" : "costweight"
            }
          ],
          "rule" : [
            {
              "name" : "Costweight",
              "source" : [
                {
                  "context" : "costweight",
                  "element" : "data",
                  "variable" : "data"
                }
              ],
              "target" : [
                {
                  "context" : "chargeItem",
                  "contextType" : "variable",
                  "element" : "factorOverride",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "data"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "ServiceProcedureToFhirProcedure",
          "source" : [
            {
              "context" : "service",
              "element" : "Procedure",
              "variable" : "proc"
            }
          ],
          "target" : [
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "contained",
              "variable" : "procedure",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Procedure"
                }
              ]
            },
            {
              "context" : "procedure",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "containedid",
              "transform" : "uuid"
            },
            {
              "context" : "chargeItem",
              "contextType" : "variable",
              "element" : "service",
              "variable" : "service",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "service",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'#' + %containedid"
                }
              ]
            }
          ],
          "dependent" : [
            {
              "name" : "ServiceProcedureToFhirProcedure",
              "variable" : [
                "proc",
                "procedure"
              ]
            }
          ]
        }
      ]
    },
   &nb "type" : "Service",
          "mode" : "source"
        },
        {
          "name" : "visit",
          "type" : "Visit",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "patientID",
          "source" : [
            {
              "context" : "visit",
              "element" : "PatientID",
              "variable" : "patientID"
            }
          ],
          "rule" : [
            {
              "name" : "R22PatientPIDPatientID",
              "source" : [
                {
                  "context" : "patientID",
                  "element" : "data",
                  "variable" : "patId"
                }
              ],
              "target" : [
                {
                  "context" : "patient",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                },
                {
                  "context" : "identifier",
                  "contextType" : "variable",
                  "element" : "value",
                  "variable" : "value"
                },
                {
                  "context" : "value",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "patId"
                    }
                  ]
                },
                {
                  "context" : "identifier",
                  "contextType" : "variable",
                  "element" : "system",
                  "variable" : "idsystem"
                },
                {
                  "context" : "idsystem",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "http://www.example.ch/patienteniddomain"
                    }
                  ]
                },
                {
                  "context" : "identifier",
                  "contextType" : "variable",
                  "element" : "type",
                  "variable" : "type"
                },
                {
                  "context" : "type",
                  "contextType" : "variable",
                  "element" : "coding",
                  "variable" : "coding"
                },
                {
                  "context" : "coding",
                  "contextType" : "variable",
                  "element" : "system",
                  "variable" : "system"
                },
                {
                  "context" : "system",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "http://terminology.hl7.org/CodeSystem/v2-0203"
                    }
                  ]
                },
                {
                  "context" : "coding",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "code"
                },
                {
                  "context" : "code",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "MR"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "ServiceToPatient",
          "source" : [
            {
              "context" : "visit",
              "condition" : "(visit.PatientName or visit.PatientGivenName)"
            }
          ],
          "target" : [
            {
              "context" : "patient",
              "contextType" : "variable",
              "element" : "name",
              "variable" : "name"
            }
          ],
          "dependent" : [
            {
              "name" : "ServiceToPatientName",
              "variable" : [
                "visit",
                "name"
              ]
            }
          ]
        },
        {
          "name" : "R26PatientGeschlechtPatientGender",
          "source" : [
            {
              "context" : "visit",
              "element" : "PatientGender",
              "variable" : "gender"
            }
          ],
          "rule" : [
            {
              "name" : "gender",
              "source" : [
                {
                  "context" : "gender",
                  "element" : "data",
                  "variable" : "v"
                }
              ],
              "target" : [
                {
                  "context" : "patient",
                  "contextType" : "variable",
                  "element" : "gender",
                  "transform" : "translate",
                  "parameter" : [
                    {
                      "valueId" : "v"
                    },
                    {
                      "valueString" : "#gender"
                    },
                    {
                      "valueString" : "code"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "R25PatientGebDatumPatientBirthDate",
          "source" : [
            {
              "context" : "visit",
              "element" : "PatientBirthDate",
              "variable" : "birthDate"
            }
          ],
          "rule" : [
            {
              "name" : "birthDate",
              "source" : [
                {
                  "context" : "birthDate",
                  "element" : "data",
                  "variable" : "v"
                }
              ],
              "target" : [
                {
                  "context" : "patient",
                  "contextType" : "variable",
                  "element" : "birthDate",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "v"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "DiagnosisToCondition",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "diagnosis",
          "type" : "Diagnosis",
          "mode" : "source"
        },
        {
          "name" : "cond",
          "type" : "Condition",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "containedpatient",
          "source" : [
            {
              "context" : "diagnosis"
            }
          ],
          "target" : [
            {
              "context" : "cond",
              "contextType" : "variable",
              "element" : "subject",
              "variable" : "ref",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "ref",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "#pat"
                }
              ]
            }
          ]
        },
        {
          "name" : "Identifier",
          "source" : [
            {
              "context" : "diagnosis",
              "element" : "Identifier",
              "variable" : "identifier"
            }
          ],
          "rule" : [
            {
              "name" : "identifier",
              "source" : [
                {
                  "context" : "identifier",
                  "element" : "data",
                  "variable" : "data"
                }
              ],
              "target" : [
                {
                  "context" : "cond",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                },
                {
                  "context" : "identifier",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "data"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "R316ProzedurcodeCode",
          "source" : [
            {
              "context" : "diagnosis",
              "element" : "Code",
              "variable" : "code"
            }
          ],
          "target" : [
            {
              "context" : "cond",
              "contextType" : "variable",
              "element" : "code",
              "variable" : "cc",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "CodeableConcept"
                }
              ]
            },
            {
              "context" : "cc",
              "contextType" : "variable",
              "element" : "coding",
              "variable" : "coding",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Coding"
                }
              ]
            },
            {
              "context" : "coding",
              "contextType" : "variable",
              "element" : "code",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%code.data"
                }
              ]
            },
            {
              "context" : "coding",
              "contextType" : "variable",
              "element" : "display",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%diagnosis.Display.data"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "serviceType",
              "source" : [
                {
                  "context" : "diagnosis",
                  "element" : "Category",
                  "variable" : "category"
                }
              ],
              "rule" : [
                {
                  "name" : "data",
                  "source" : [
                    {
                      "context" : "category",
                      "element" : "data",
                      "variable" : "data",
                      "condition" : "(startsWith('ICD'))"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "coding",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "http://hl7.org/fhir/sid/icd-10"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "onsetDateTime",
          "source" : [
            {
              "context" : "diagnosis",
              "element" : "OnsetDateTime",
              "variable" : "onsetDateTime"
            }
          ],
          "target" : [
            {
              "context" : "cond",
              "contextType" : "variable",
              "element" : "onset",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "%onsetDateTime.data"
                }
              ]
            }
          ]
        },
        {
          "name" : "laterality",
          "source" : [
            {
              "context" : "diagnosis",
              "element" : "Laterality",
              "variable" : "laterality"
            }
          ],
          "rule" : [
            {
              "name" : "R318SeiteLaterality",
              "source" : [
                {
                  "context" : "laterality",
                  "element" : "data",
                  "variable" : "v"
                }
              ],
              "target" : [
                {
                  "context" : "cond",
                  "contextType" : "variable",
                  "element" : "bodySite",
                  "variable" : "cc",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "CodeableConcept"
                    }
                  ]
                },
                {
                  "context" : "cc",
                  "contextType" : "variable",
                  "element" : "coding",
                  "variable" : "coding",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Coding"
                    }
                  ]
                },
                {
                  "context" : "coding",
                  "contextType" : "variable",
                  "element" : "code",
                  "transform" : "translate",
                  "parameter" : [
                    {
                      "valueId" : "v"
                    },
                    {
                      "valueString" : "#laterality"
                    },
                    {
                      "valueString" : "code"
                    }
                  ]
                },
                {
                  "context" : "coding",
                  "contextType" : "variable",
                  "element" : "system",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "http://snomed.info/sct"
                    }
                  ]
                },
                {
                  "context" : "coding",
                  "contextType" : "variable",
                  "element" : "display",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "%diagnosis.LateralityDisplay.data"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "DiagGroupToCondition",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "diagGroup",
          "type" : "DiagGroup",
          "mode" : "source"
        },
        {
          "name" : "cond",
          "type" : "Condition",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "containedpatient",
          "source" : [
            {
              "context" : "diagGroup"
            }
          ],
          "target" : [
            {
              "context" : "cond",
              "contextType" : "variable",
              "element" : "subject",
              "variable" : "ref",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "ref",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "#pat"
                }
              ]
            }
          ]
        },
        {
          "name" : "R291DiagnosecodeDiagCode",
          "source" : [
            {
              "context" : "diagGroup",
              "element" : "DiagCode",
              "variable" : "data"
            }
          ],
          "target" : [
            {
              "context" : "cond",
              "contextType" : "variable",
              "element" : "code",
              "variable" : "cc",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "CodeableConcept"
                }
              ]
            },
            {
              "context" : "cc",
              "contextType" : "variable",
              "element" : "coding",
              "variable" : "coding",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Coding"
                }
              ]
            },
            {
              "context" : "coding",
              "contextType" : "variable",
              "element" : "code",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueId" : "data"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "serviceType",
              "source" : [
                {
                  "context" : "diagGroup",
                  "element" : "DiagCatType",
                  "variable" : "diagCatType"
                }
              ],
              "rule" : [
                {
                  "name" : "R293KatalogtypDiagCatType",
                  "source" : [
                    {
                      "context" : "diagCatType",
                      "element" : "data",
                      "variable" : "data"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "coding",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "translate",
                      "parameter" : [
                        {
                          "valueId" : "data"
                        },
                        {
                          "valueString" : "#serviceMap"
                        },
                        {
                          "valueString" : "code"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "TerminationToExtension",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "visit",
          "type" : "Visit",
          "mode" : "source"
        },
        {
          "name" : "ext",
          "type" : "Extension",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "TerminationVisit",
          "source" : [
            {
              "context" : "visit",
              "element" : "TerminationVisit",
              "variable" : "visit"
            }
          ],
          "rule" : [
            {
              "name" : "R27FallAbschlussTerminationVisit",
              "source" : [
                {
                  "context" : "visit",
                  "element" : "data",
                  "variable" : "data"
                }
              ],
              "target" : [
                {
                  "context" : "ext",
                  "contextType" : "variable",
                  "element" : "extension",
                  "variable" : "ext1"
                },
                {
                  "context" : "ext1",
                  "contextType" : "variable",
                  "element" : "url",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "TerminationVisit"
                    }
                  ]
                },
                {
                  "context" : "ext1",
                  "contextType" : "variable",
                  "element" : "value",
                  "variable" : "date",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "date"
                    }
                  ]
                },
                {
                  "context" : "date",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "data"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TerminationVisit",
          "source" : [
            {
              "context" : "visit",
              "element" : "TerminationReason",
              "variable" : "visit"
            }
          ],
          "rule" : [
            {
              "name" : "R28FallAbschlussgrundTerminationReason",
              "source" : [
                {
                  "context" : "visit",
                  "element" : "data",
                  "variable" : "data"
                }
              ],
              "target" : [
                {
                  "context" : "ext",
                  "contextType" : "variable",
                  "element" : "extension",
                  "variable" : "ext1"
                },
                {
                  "context" : "ext1",
                  "contextType" : "variable",
                  "element" : "url",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "TerminationReason"
                    }
                  ]
                },
                {
                  "context" : "ext1",
                  "contextType" : "variable",
                  "element" : "value",
                  "variable" : "string",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "string"
                    }
                  ]
                },
                {
                  "context" : "string",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "data"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "VisitToEncounter",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "visit",
          "type" : "Visit",
          "mode" : "source"
        },
        {
          "name" : "encounter",
          "type" : "Encounter",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "TerminationToExtension",
          "source" : [
            {
              "context" : "visit",
              "condition" : "(visit.TerminationVisit or visit.TerminationReason)"
            }
          ],
          "target" : [
            {
              "context" : "encounter",
              "contextType" : "variable",
              "element" : "extension",
              "variable" : "ext"
            },
            {
              "context" : "ext",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "http://fhir.ch/ig/ch-alis/StructureDefinition/ch-alis-ext-termination"
                }
              ]
            }
          ],
          "dependent" : [
            {
              "name" : "TerminationToExtension",
              "variable" : [
                "visit",
                "ext"
              ]
            }
          ]
        },
        {
          "name" : "encounterID",
          "source" : [
            {
              "context" : "visit",
              "element" : "VisitNumber",
              "variable" : "visitNumber"
            }
          ],
          "rule" : [
            {
              "name" : "R21FallVisitNumber",
              "source" : [
                {
                  "context" : "visitNumber",
                  "element" : "data",
                  "variable" : "data"
                }
              ],
              "target" : [
                {
                  "context" : "encounter",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Identifier"
                    }
                  ]
                },
                {
                  "context" : "identifier",
                  "contextType" : "variable",
                  "element" : "value",
                  "variable" : "value"
                },
                {
                  "context" : "value",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "data"
                    }
                  ]
                },
                {
                  "context" : "identifier",
                  "contextType" : "variable",
                  "element" : "system",
                  "variable" : "idsystem"
                },
                {
                  "context" : "idsystem",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "http://www.example.ch/fallnummerdomain"
                    }
                  ]
                },
                {
                  "context" : "identifier",
                  "contextType" : "variable",
                  "element" : "type",
                  "variable" : "type"
                },
                {
                  "context" : "type",
                  "contextType" : "variable",
                  "element" : "coding",
                  "variable" : "coding"
                },
                {
                  "context" : "coding",
                  "contextType" : "variable",
                  "element" : "system",
                  "variable" : "system"
                },
                {
                  "context" : "system",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "http://terminology.hl7.org/CodeSystem/v2-0203"
                    }
                  ]
                },
                {
                  "context" : "coding",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "code"
                },
                {
                  "context" : "code",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "VN"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "Finished",
          "source" : [
            {
              "context" : "visit"
            }
          ],
          "target" : [
            {
              "context" : "encounter",
              "contextType" : "variable",
              "element" : "status",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "finished"
                }
              ]
            }
          ]
        },
        {
          "name" : "R21FallVisitNumber",
          "source" : [
            {
              "context" : "visit"
            }
          ],
          "target" : [
            {
              "context" : "encounter",
              "contextType" : "variable",
              "element" : "class",
              "variable" : "coding"
            },
            {
              "context" : "coding",
              "contextType" : "variable",
              "element" : "system",
              "variable" : "system"
            },
            {
              "context" : "system",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "http://terminology.hl7.org/CodeSystem/v3-ActCode"
                }
              ]
            },
            {
              "context" : "coding",
              "contextType" : "variable",
              "element" : "code",
              "variable" : "code"
            },
            {
              "context" : "code",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "IMP"
                }
              ]
            },
            {
              "context" : "coding",
              "contextType" : "variable",
              "element" : "display",
              "variable" : "display"
            },
            {
              "context" : "display",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "inpatient encounter"
                }
              ]
            }
          ]
        },
        {
          "name" : "subject",
          "source" : [
            {
              "context" : "visit"
            }
          ],
          "target" : [
            {
              "context" : "encounter",
              "contextType" : "variable",
              "element" : "subject",
              "variable" : "ref",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "ref",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "#pat"
                }
              ]
            }
          ]
        },
        {
          "name" : "R29DiagnoseGruppeDiagGroup",
          "source" : [
            {
              "context" : "visit",
              "element" : "DiagGroup",
              "variable" : "diaggroup"
            }
          ],
          "target" : [
            {
              "context" : "encounter",
              "contextType" : "variable",
              "element" : "diagnosis",
              "variable" : "diag"
            },
            {
              "context" : "diag",
              "contextType" : "variable",
              "element" : "condition",
              "variable" : "ref",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "ref",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "#cond"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "R292DiagnosetypDiagType",
              "source" : [
                {
                  "context" : "diaggroup",
                  "element" : "DiagType",
                  "variable" : "diagType"
                }
              ],
              "target" : [
                {
                  "context" : "diag",
                  "contextType" : "variable",
                  "element" : "use",
                  "variable" : "use"
                },
                {
                  "context" : "use",
                  "contextType" : "variable",
                  "element" : "text",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "%diagType.data"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

XIG built as of ??metadata-date??. Found ??metadata-resources?? resources in ??metadata-packages?? packages.